/**
 * @file .
 * @author wangxiaowei0303@163.com
 */

#include <stdio.h>
#include "NoiseAlgorithm.h"

AlgoMap NoiseAlgorithm::algos_;

NoiseAlgorithm*
NoiseAlgorithm::create(const std::string &algoname)
{
    AlgoMap::iterator algoptr = NoiseAlgorithm::algos_.find(algoname);
    if (algoptr == NoiseAlgorithm::algos_.end())
        return 0;
    return (*algoptr->second)();
}

NoiseAlgorithmUtil::NoiseAlgorithmUtil(const std::string &name,
    AlgoRegFunc algoregfunc)
{
#ifdef ENABLE_DEBUG
    printf("DEBUG;NoiseAlgorithmUtil(%s,%p)\n",name.c_str(),algoregfunc);
#endif
    AlgoMap::iterator algoiter = NoiseAlgorithm::algos_.find(name);
    if (algoiter != NoiseAlgorithm::algos_.end()) {
        printf("WARNING;算法 %s 已经存在,将被覆盖\n",algoiter->first.c_str());
        return ;
    }
    NoiseAlgorithm::algos_[name] = algoregfunc;
    return ;
}

NoiseAlgorithm::~NoiseAlgorithm()
{
    ;
}

